/*
 * @Author: shiweizhen 787632169@qq.com
 * @Date: 2025-06-26 09:16:31
 * @LastEditors: shiweizhen 787632169@qq.com
 * @LastEditTime: 2025-07-03 16:53:21
 * @Description:
 * Copyright (c) 2025-present HBIS Digital Technology Co.,Ltd. All rights reserved.
 */
import { default as request } from '@/framework/utils/request';
import { ID, ResultData } from 'hbisdt-design';
import { DatasetType, DatasetDetailType, ProjectType } from './types';

/**
 * 获取数据集列表
 * @returns
 */
export const getDatasetList = (): Promise<ResultData<DatasetType[]>> => {
  return request({
    method: 'GET',
    url: '/dataset/list'
  });
};

/**
 * 获取数据集详情 字段信息
 * @param datasetId
 * @returns
 */
export const getDatasetDetail = (
  id: ID
): Promise<ResultData<DatasetDetailType[]>> => {
  return request({
    method: 'GET',
    url: `/dataset/detail`,
    params: { id }
  });
};

/**
 * 获取中间层列表
 * @returns
 */
export const getMiddleList = (
  projectName: string
): Promise<ResultData<{ records: ProjectType[] }>> => {
  return request({
    method: 'GET',
    url: '/middleCalculate/page',
    params: { pageNo: 1, pageSize: 100000, projectName }
  });
};

/**
 * 保存中间层
 * @param data
 * @returns
 */
export const saveMiddle = (data: ProjectType) => {
  return request({
    method: 'POST',
    url: '/middleCalculate/save',
    data
  });
};

/**
 * 编辑中间层
 * @param data
 * @returns
 */
export const editMiddle = (data: ProjectType) => {
  return request({
    method: 'POST',
    url: '/middleCalculate/edit',
    data
  });
};

/**
 * 删除中间层
 * @param id
 * @returns
 */
export const deleteMiddle = (id: ID) => {
  return request({
    method: 'DELETE',
    url: `/middleCalculate/delete`,
    params: { id }
  });
};

export const copyMiddle = (id: ID) => {
  return request({
    method: 'GET',
    url: '/middleCalculate/copy',
    params: { id }
  });
};
